import React from 'react'
import {useSelector,useDispatch} from 'react-redux'
import {increment,subtraction} from '../store/modules/counter'
export default function Counter() {
  const count=useSelector((state)=>{
    console.log('---',state);
    return state.jsq.num
  })
  const dispatch=useDispatch()
  const add=(n)=>{
    dispatch(increment(n))
  }
  const sub=(n)=>{
    dispatch(subtraction(n))
  }
  return (
    <div>
        <h2>RTX版的计算器</h2>
        <div>{count}</div>
        <button onClick={()=>{add(5)}}>更新</button>
        <button onClick={()=>{sub(2)}}>更新-</button>
    </div>
  )
}
